package com.idealighter.game.games.fruitslot.struct;

/**
 * 编码.
 * <ul>
 * .
 * <li>1 . WILD 鬼</li>
 * <li>2 . BONUS 橘子</li>
 * <li>3 . banana 香蕉</li>
 * <li>4 . watermelon 西瓜</li>
 * <li>5 . lemon 柠檬</li>
 * <li>6 . BAR BAR</li>
 * <li>7 . grape 葡萄</li>
 * <li>8 . strawberry 草莓</li>
 * <li>9 . cherry 樱桃</li>
 * <li>10 . apple 青苹果</li>
 * <li>11 . pawpaw 木瓜</li>
 * </ul>
 * .
 *
 */
public enum FruitslotDifficulty {
  /**
   * HARDEST . 最难.
   */
  HARDEST(-2, "最难", new int[] { 300, 500, 2100, 2000, 1200, 500, 1000, 1000, 800, 500, 50 }),
  /**
   * DIFFICULT . 困难.
   */
  DIFFICULT(-1, "困难", new int[] { 400, 500, 2100, 2000, 1200, 500, 900, 900, 700, 500, 50 }),
  /**
   * 普通.
   */
  NORMAL(0, "普通", new int[] { 600, 600, 3000, 2000, 2000, 1000, 1500, 1500, 1500, 800, 200 }),
  /**
   * 简单.
   */
  EASY(1, "简单", new int[] { 600, 600, 3000, 2000, 2000, 2000, 1500, 1500, 1500, 800, 200 }),
  /**
   * 轻松.
   */
  EASIEST(2, "轻松", new int[] { 1000, 800, 8000, 8000, 3000, 1500, 1000, 1000, 500, 500, 500 }),;
  // 难度
  private final int difficulty;
  // 名称
  private final String name;

  public int getDifficulty() {
    return difficulty;
  }

  public String getName() {
    return name;
  }

  public int[] getWeights() {
    return weights;
  }

  // 权重
  private final int[] weights;

  /**
   * 构造函数.
   * 
   * @param difficulty 难度.
   * @param weights 权重列表.
   */
  private FruitslotDifficulty(int difficulty, String name, int[] weights) {
    this.difficulty = difficulty;
    this.name = name;
    this.weights = weights;
  }

  /**
   * 权重和.
   * 
   * @return 权重和.
   */
  public int totalWeight() {
    int totalWeight = 0;
    for (int weight : weights) {
      totalWeight += weight;
    }

    return totalWeight;
  }

  /**
   * 获取难度.
   * 
   * @param difficulty 难度值.
   * @return 难度》
   */
  public static FruitslotDifficulty get(int difficulty) {
    for (FruitslotDifficulty d : values()) {
      if (d.difficulty == difficulty) {
        return d;
      }
    }

    return null;
  }

}
